// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package com.zzx.settings;

import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.FormBuilder;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * Supports creating and managing a {@link JPanel} for the Settings Dialog.
 */
public class AppSettingsComponent {

  private final JPanel myMainPanel;
  private final JBTextField repository = new JBTextField();
  private final JBTextField nexus = new JBTextField();
  private final JBTextField username = new JBTextField();
  private final JBLabel message = new JBLabel();
  private final JPasswordField password = new JPasswordField();

  public AppSettingsComponent() {
    myMainPanel = FormBuilder.createFormBuilder()
            .addLabeledComponent(new JBLabel("本地Maven仓库路径: "), repository, 1, false)
            .addLabeledComponent(new JBLabel("Maven私服上传地址: "), nexus, 1, false)
            .addLabeledComponent(new JBLabel("Maven私服用户名: "), username, 1, false)
            .addLabeledComponent(new JBLabel("Maven私服密码: "), password, 1, false)
            .addLabeledComponent(new JBLabel(""), message, 1, false)
            .addComponentFillVertically(new JPanel(), 0)
            .getPanel();
  }

  public JPanel getPanel() {
    return myMainPanel;
  }


  @NotNull
  public String getRepositoryText() {
    return repository.getText();
  }

  public void setRepositoryText(@NotNull String newText) {
    repository.setText(newText);
  }

  public String getNexusText() {
    return nexus.getText();
  }
  public void setNexusText(@NotNull String newText) {
    nexus.setText(newText);
  }
  public String getUsernameText() {
    return username.getText();
  }
  public void setUsernameText(@NotNull String newText) {
    username.setText(newText);
  }

  public String getPasswordText() {
    return password.getText();
  }
  public void setPasswordText(@NotNull String newText) {
    password.setText(newText);
  }
  public void setMessageText(@NotNull String newText) {
    message.setText(newText);
  }

}
